<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<base th:href="@{/}" />
<title>Insert title here</title>
<script src="js/jquery-3.4.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/Managerstyle.css" />
<script>
	function modifyGrade(srollno, cpid){
		$("#grade" + srollno).removeAttr("disabled");
		$("#function" + srollno).empty();
		var str1 = "<a href=\"javascript:confirmGrade('" + srollno + "','" + cpid + "')\">" + "确认</a>";
		$("#function" + srollno).append(str1);
	}
	
	function confirmGrade(srollno, cpid){
		$("#grade" + srollno).attr("disabled","disabled");
		$("#function" + srollno).empty()
		var str1 = "<a href=\"javascript:modifyGrade('" + srollno + "','" + cpid + "')\">" + "修改</a>";
		$("#function" + srollno).append(str1);
		$.ajax({
			url: "teach/giveGradeToStudent",
			type: "GET",
			data: {srollno: srollno, cpid: cpid, grade: $("#grade" + srollno).val()},
			success: function(data){
			},
			error: function(req, status, error){
			}
		});
	}
	
</script>

</head>
<body>
	<div class="contain">
		<h3>上传和修改学生成绩</h3>
		<a th:href="|teach/downloadStudentByBid?bid=${bid}|" style="float:right;">下载学生列表</a>
		<a th:href="|teach/downloadGradeMould?bid=${bid}&cpid=${cpid}|" style="float:right; margin-right: 5px;">下载成绩上传模板</a>
		<table class="table">
			<tr>
				<td width="250">学号</td>
				<td width="">姓名</td>
				<td width="">性别</td>
				<td width="">班级</td>
				<td width="170">成绩</td>
				<td width="128">操作</td>
			</tr>
			<tr th:each="stu,status:${stuList}">
				<td>
					[[${stu.srollno}]]
					<input type="text" th:value="${stu.srollno}" hidden />
				</td>
				<td>
					[[${stu.sname}]]
					<input type="text" th:value="${stu.sname}" hidden />
				</td>
				<td>
					[[${stu.sgender}]]
				</td>
				<td>
					[[${stu.batch.bname}]]
					<input type="text" th:value="${stu.batch.bname}" hidden />
				</td>
				<td>
					<input type="number" th:value="${gradeList[status.index]}==null?0:${gradeList[status.index].grade}" th:id="grade+${stu.srollno}" disabled="disabled"/>
				</td>
				<td th:id="|function${stu.srollno}|">
					<a th:href="|javascript:modifyGrade('${stu.srollno}','${cpid}')|">修改</a>
				</td>
			</tr>
		</table>
		<form enctype="multipart/form-data" method="post" action="teach/uploadGrade">
			<input type="file" id="file" name="file" style="display: none" /> 
			<input type="text"  name="bid" th:value="${bid}" style="display: none" /> 
			<input type="text" name="cpid" th:value="${cpid}" style="display: none" /> 
			<input type="submit" id="submit" value="上传" class="btn btn-success" style="float:right" />
			<label for="file" style="float:right;display: inline-block;text-align: center; line-height:32px ;height: 32px;width:80px; ">＋选择文件</label>
		</form>
	</div>
	
	
</body>
</html>  